package com.realgodo.site.web.tag;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springside.modules.web.struts2.Struts2Utils;

import com.realgodo.site.entity.site.Advertisement;
import com.realgodo.site.service.site.AdvertisementManager;

@Scope("prototype")
public class AdvController {

	private String code;

	@Resource
	private AdvertisementManager advertisementManager;

	public String execute() {
		if (getCode() != null && !getCode().isEmpty()) {
			Advertisement adv = advertisementManager.getByCode(getCode());
			Struts2Utils.getRequest().setAttribute("adv", adv);
		}

		return null;
	}

	/*************** getter and setter *******************/
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

}
